function enqueueST()
	%Includes
	global Q_LIMIT;
	global BUSY;
	global IDLE;
	global INFINITY;

	global next_event_type;
	global num_custs_delayed;
	global num_delays_required;
	global num_events;
	global num_in_q;
	global server_status;

	global arrivals_mean;
	global client_times;
	global arrival_times;

	%Variables de la UI
	global ui_queue_len;
	global ui_status;
	global ui_mean;

	global ui_serving;
	%% Variables de tiempos de servicio

	%Variables de las ERs
	global er_queue_len;
	global er_status;
	global er_next_event;
	global er_next_free;
	global er_mean;
	global num_er_busy;

	global er_queue;
	global er_queue_index;
	global er_queue_last;
	global er_queue_max_items;
	global er_serving;
	%% Variables de tiempos de servicio

	%Variables de la ST
	global st_queue_len;
	global st_status;
	global st_mean;
	global st_pass;

	%%QUEUE
	global st_queue;
	global st_queue_index;
	global st_queue_last;
	global st_queue_max_items;
	global st_serving;
	%% Variables de tiempos de servicio

	global time;
	global num_arrivals;
	global time_arrival;
	global time_last_event;
	global time_next_event;
	global total_of_delays;

	%Estadisticas
	global area_ui_queue;
	global area_er_queue;
	global area_st_queue;

	global area_ui_status;
	global area_er1_status;
	global area_er2_status;
	global area_er3_status;
	global area_st_status;


	time_next_event(6) = INFINITY;
	st_status = IDLE;

	%printf("Client %d is requeued.\n",st_serving);

	if( num_er_busy < 3 )
		%Ocupar una ER
		num_er_busy++;
		next = time + mi_randtraing(lecuyer_rand(),0,1.125,1.75);	%Calcular el proximo evento de salida

		i = 0;

		%Lo pongo en la primer ER libre
		for i=1:3
			if( er_next_event(i) == INFINITY )
				er_next_event(i) = next;
				er_serving(i) = st_serving;
				break;
			end
		end

		%Veo si el tiempo de salida que acabo de calcular es menor al primero que iba a salir antes
		if( next < time_next_event(4) )
			%Si es menor, me quedo con el tiempo y asigno la er que se va a liberar.
			time_next_event(4) = next;
			er_next_free = i;
		end

		client_times(st_serving,3) = time - arrival_times(st_serving,3);
		arrival_times(st_serving,4) = next;
	else
		%Poner en la cola
		er_queue_len++;
		er_queue(er_queue_last) = st_serving;
		er_queue_last++;
		er_queue_last = mod(er_queue_last,er_queue_max_items);
		if( er_queue_last == 0 )
			er_queue_last = 1;
		end
		if( er_queue_last == er_queue_index )
			printf("Error: No hay mas espacio en la cola de ERs\n");
			exit(1);
		end
	end

	if( st_queue_len > 0 )
		st_status = BUSY;
		st_queue_len--;

		%Desencolo uno:
		first_in_queue = st_queue(st_queue_index);
		st_queue_index++;
		st_queue_index = mod(st_queue_index,st_queue_max_items);

		if( er_queue_index == 0 )
			st_queue_index = 1;
		end

		client_times(first_in_queue,4) = time - arrival_times(first_in_queue,4);

		st_serving = first_in_queue;

		next = time + exprnd(st_mean); 	%%Calculo el tiempo de servicio
		leave = lecuyer_rand();		%%Calculo la prob q se vaya del sistema

		%Veo si el colectivo se va del sistema o es realimentado
		if( leave < st_pass )
			%Calculo el proximo evento de salida (Se va del sistema)
			time_next_event(5) = next;
			time_next_event(6) = INFINITY;
		else
			arrival_times(st_serving,3) = next;
			time_next_event(6) = next;
			time_next_event(5) = INFINITY;
		end
	end
endfunction
